'''
Created on Jul 13, 2011

@author: ioan
'''
from Model.GenericNode import GenericNode
from Model.NodeFolder import NodeFolder
from Model.NodeEntity import NodeEntity
from Model.Entity import Entity
from Model.TreeModel import TreeModel
from PyQt4.QtCore import pyqtSignal, QObject, pyqtSlot


class Scene(QObject):
    '''
    A 3dk scene used to represent a stage/level in the game
    '''
    mSignalChanged = pyqtSignal(GenericNode)

    def __init__(self):
        '''
        Constructor
        '''
        super(Scene, self).__init__()
        self.mRootNode = self.GenerateNodes()
        self.mModel = TreeModel(["Scene"], [self.mRootNode])


    def GenerateNodes(self):

        rootNode = GenericNode(["Project"])

        hardFolder0 = NodeFolder("Folder1")
        rootNode.addChildNode(hardFolder0)
        hardEnt1 = NodeEntity(Entity("/Folder1/Entity1"))
        hardEnt2 = NodeEntity(Entity("/Folder1/Entity2"))
        hardFolder0.addChildNode(hardEnt1)
        hardFolder0.addChildNode(hardEnt2)

        hardFolder1 = NodeFolder("Folder2")
        rootNode.addChildNode(hardFolder1)
        hardEnt3 = NodeEntity(Entity("/Folder2/Entity3") )
        hardEnt4 = NodeEntity(Entity("/Folder2/SubEntity1") )
        hardEnt5 = NodeEntity(Entity("/Folder2/SubEntity2") )
        hardFolder1.addChildNode(hardEnt3)
        hardEnt3.addChildNode(hardEnt4)
        hardEnt3.addChildNode(hardEnt5)

        return rootNode;

    def addFolder(self, foldername):
        node = NodeFolder(foldername)
        self.mRootNode.addChildNode(node)
        self.mSignalChanged.emit(node)
